#include "krtpch.h"

#include "../../include/Hit/Primitive.h"
#include "../../include/Render/Material.h"
#include "../../include/Utility/KRTMath.h"

namespace krt {

	bool Lambertian::Scatter(const Ray& rayIn, const Intersection& dg, glm::vec3& attenuation, Ray& scattered) const
	{
		attenuation *= m_Tex->GetValue(dg.uv);
		scattered = Ray(dg.hitPoint, glm::normalize(KRTMath::RandomUnitSphere() + dg.normal));
		return true;
	}

	bool Metal::Scatter(const Ray& rayIn, const Intersection& dg, glm::vec3& attenuation, Ray& scattered) const
	{
		attenuation *= m_Tex->GetValue(dg.uv);
		scattered = Ray(dg.hitPoint, glm::reflect(rayIn.direct, dg.normal));
		return true;
	}

	bool Dielectric::Scatter(const Ray& rayIn, const Intersection& dg, glm::vec3& attenuation, Ray& scattered) const
	{
		return true;
	}

	bool Illumination::Scatter(const Ray& rayIn, const Intersection& dg, glm::vec3& attenuation, Ray& scattered) const
	{
		return false;
	}

}